import time
from data001.Tools.Tools import Tools
from data001.Page.Page1 import Page1
from selenium.webdriver.common.by import By
class Page3(Page1):
    # 点击团购
    TuanGo_loc = (By.LINK_TEXT,'团购')
    def TuanGo(self):
        self.click(self.TuanGo_loc)
    # 点击团购商品   红米k80至尊版
    click_sp_loc = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[6]/div[1]/span/a/img')
    def click_sp(self):
        self.click(self.click_sp_loc)
    # 断言1   进入团购详情页
    dy1_loc= (By.XPATH,'/html/body/div[4]/a[3]')
    def dy1(self):
        self.click(self.dy1_loc)
    # 点击立即购买
    click_goumai_loc = (By.ID, 'buy-cart')
    def click_goumai(self):
        self.click(self.click_goumai_loc)
    # 断言2  进入确认订单页
    dy3_loc = (By.XPATH, '/html/body/div[4]/div[1]/a[2]')
    def dy3(self):
        return self.text(self.dy3_loc)
    # 添加地址
    address_loc = (By.NAME, 'address_id')
    def address(self):
        self.click(self.address_loc)
    # 点击支付方式
    payment_loc = (By.NAME, 'payment')
    def payment(self):
        self.click(self.payment_loc)
    # 点击下一步
    order_button_loc = (By.ID, 'order-button')
    def order_button(self):
        self.click(self.order_button_loc)
    # 点击查看订单
    immediate_loc = (By.CLASS_NAME, 'immediate-pay')
    def immediate(self):
        self.click(self.immediate_loc)

    def test_a3mall_tuangou(self):
        Tools().Log()
        self.test_a3mall_login()
        time.sleep(3)
        self.TuanGo()
        self.click_sp()
        time.sleep(2)
        print('断言1:',self.dy1())
        self.click_goumai()
        time.sleep(2)
        print('断言2', self.dy3())
        self.address()
        self.payment()
        time.sleep(2)
        self.order_button()
        self.immediate()
        time.sleep(3)

